from django import forms

from supergirl.models import ConsultRecord
from gideon.service.starlabs import GideonModelForm


class ConsultRecordModelForm(GideonModelForm):
    title = forms.CharField(
        required=True,
        widget=forms.widgets.TextInput(attrs={'placeholder': '显示题目'}),
        max_length=32,
        strip=True,
        label="显示题目",
        error_messages={
            'required': "显示题目未填",
        }
    )
    note = forms.CharField(
        required=True,
        widget=forms.widgets.Textarea(attrs={'placeholder': '跟进内容'}),
        strip=True,
        label="跟进内容",
        error_messages={
            'required': "跟进内容未填",
        }
    )
    link_name = forms.CharField(
        required=False,
        widget=forms.widgets.TextInput(attrs={'placeholder': '链接地址'}),
        max_length=128,
        strip=True,
        label="链接地址",
    )
    link_title = forms.CharField(
        required=False,
        widget=forms.widgets.TextInput(attrs={'placeholder': '链接标题'}),
        max_length=128,
        strip=True,
        label="链接标题",
    )
    icon = forms.CharField(
        required=False,
        widget=forms.widgets.TextInput(attrs={'placeholder': '显示图标'}),
        max_length=16,
        strip=True,
        label="显示图标",
    )

    class Meta:
        model = ConsultRecord
        fields = ["title", "note", "link_name", "link_title", "icon"]
